home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / Papers / Downs.FileSystem / source / patch / FilePatches.h < prev   
Encoding:
C/C++ Source or Header  |  1999-06-24  |  1.8 KB  |  80 lines  |  [TEXT/CWIE]

  1. #define    MacroPreProcess    movem.l    a0/a4/d0-d1, -( sp );\
  2.         movem.l    a0, -( sp );\
  3.         jsr        SetCurrentA4;\
  4.         movem.l    ( sp )+, a0;\
  5.         fralloc;
  6.  
  7. #define    MacroSaveValues    move.l    a0, d0;\
  8.         move.l    d0, -( sp );\
  9.         jsr        CopyHParamBlockValues;\
  10.         frfree;
  11.  
  12. #define    MacroCallOriginalTrap    movem.l    ( sp )+, a0/a4/d0-d1;\
  13.         jsr        ( a1 );\
  14.         tst.w    d0;\
  15.         bne        getOut;\
  16.         movem.l    a0-a7/d0-d7, -( sp );\
  17.         movem.l    a0/d0, -( sp );\
  18.         jsr        SetCurrentA4;\
  19.         movem.l    ( sp )+, a0/d0;\
  20.         jsr        SetArrayElement;\
  21.         movem.l    ( sp )+, a0-a7/d0-d7;\
  22. getOut:\
  23.         rts;
  24.  
  25. //    Global variables.
  26. long                    gNextFreeElement = 0L;
  27. long                    gLastRetrievedElement = 0L;
  28. Boolean                    gReentrant = false;
  29. ProcPtr                    gFSPatchProcPtr;
  30. StringPtr                gTempStringPtr;
  31. UniversalProcPtr        gCallbackProcPtr = 0L;
  32.  
  33. //    Hold all file info until success of File Mgr operation is determined.
  34. HParmBlkPtr                gParamBlockCopy = nil;
  35.  
  36. //    The parameters for _HCreate.
  37. typedef    struct    FSPatchGlobals
  38. {
  39.     short                    theTrapId;
  40.     short                    theVRefNum;
  41.     long                    theParID;
  42.     Str32                    theString;
  43.     OSType                    theFileType;
  44. }    FSPatchGlobals, *FSPatchGlobalsPtr;
  45.  
  46. enum {
  47.   kCreateFlag,
  48.   kDeleteFlag,
  49.   kCopyFlag,
  50.   kRenameFlag
  51. };
  52.  
  53. typedef    struct    FWData
  54. {
  55.     short                    theTrapId;
  56.     short                    theVRefNum;
  57.     long                    theParID;
  58.     Str63                    theString;
  59.     OSType                    theFileType;
  60. }    FWData, *FWDataPtr;
  61.  
  62. typedef    struct    FWSubscribe
  63. {
  64.     short                    theAction;
  65.     long                    theCallbackAddr;
  66. }    FWSubscribe, *FWSubscribePtr;
  67.  
  68. //    Define the callback conventions.
  69. ProcInfoType uppCreateFileProcInfo = kPascalStackBased
  70.          | RESULT_SIZE( kNoByteCode )
  71.          | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE( sizeof( FWData ) ) )
  72.          ;
  73.  
  74. //    Use an array of structs to track the calls to _Create.
  75. //    Better performance than dynamic memory allocation,
  76. //    especially for a patch.
  77. FSPatchGlobals            gFSPatchGlobals[ MAX_NUM_FILES ];
  78. #endif
  79.  
  80.